/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mydatastore;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 *
 * @author DTIT
 */
public abstract class StatementUnit {
  
  private StringBuilder sqlBuilder = new StringBuilder();
  
  protected void append(String str){
      sqlBuilder.append(str);
  }
  
  protected String getSql(){
    return sqlBuilder.toString();
  }
  
  public PreparedStatement prepare(Connection connection) throws SQLException{
    composeSql();
    return getPreparedStatement(connection);
  }
  
  protected abstract void composeSql();
  protected abstract PreparedStatement getPreparedStatement(Connection connection) throws SQLException;
}
